<template>
  <div class="mine">
    <div class="container">
      <div data-reactroot="" class="login">
        <header class="common-header"><i class="left iconfont" style="color:#07b3ef">&lt;</i>
          <h1 class="center">登录</h1><router-link class="right word" to='register'>注册</router-link></header>
        <div class="loginForm">
          <section class="bg-white">
            <div class="inputitem"><label for="username">用户名</label><input type="tel" name="username" placeholder="请输入手机号码" v-model="username"></div>
            <div class="inputitem"><label for="pwd">密码</label><input type="password" name="pwd" placeholder="请输入密码" v-model="pwd"></div>
          </section>
          <div class="btnBox"><button class="btn huge transition" @click="loginEnter()">确定</button></div>
          <div class="loginForm-forgetBox"><a class="loginForm-forget" href="#/findPassword?prePath=%2Fsetting">忘记密码</a></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
  export default {
    name: "Login",
    data(){
      return{
        username: "",
        pwd: ""
      }
    },
    methods:{
      loginEnter() {
        axios.post("/api/login",{username: this.username,pwd: this.pwd})
        .then((res) => {
          if(res.data.code){
            this.$router.history.push("/mine")
          }
        })
      }
    }
  }
</script>

<style scoped>
.container {
    font-size: 28px;
    max-width: 10rem;
    margin: 0 auto;
}
.common-header {
    display: flex;
    height: 44px;
    line-height: 44px;
    background-color: #07b3ef;
    color: #fff;
}
.common-header .left {
    font-size: 20px;
    padding-left: 0.1rem;
}
.common-header .center {
    flex-grow: 1;
    text-align: center;
    font-size: 20px;
}
.common-header .right.word {
    font-size: 16px;
    color: white;
    margin-right: 12px;
}
.bg-white {
    background-color: #fff;
    font-size: 14px;
}
.inputitem {
    display: flex;
    height: 0.4rem;
    background-color: #fff;
    justify-content: space-between;
    align-items: center;
    margin-left: 0.1rem;
    padding-right: 0.1rem;
}
.inputitem label {
    width: 0.6rem;
}
.inputitem input {
    flex-grow: 1;
}
button, input, select, textarea {
    outline: none;
    border: none;
}
.inputitem:not(:first-child) {
    border-top: 1px solid #ddd;
}
.btn, .btnBox {
    text-align: center;
}

.btnBox {
    margin-top: 0.22rem;
}
.btn.huge {
    font-size: 14px;
    color: #ddd;
    background: #07b3ef;
}
.btn.huge {
    width: 2.6rem;
    height: 0.4rem;
    line-height: 0.4rem;
    font-size: 18px;
}
.loginForm-forgetBox {
    margin-top: 0.1rem;
    text-align: center;
}
.loginForm-forgetBox .loginForm-forget {
    color: #999;
    font-size: 12px;
}
</style>
